<?php
require_once dirname(__FILE__).'/../bootstrap/unit.php';

class unit_PriceCalculatorTest extends sfPHPUnitBaseTestCase
{
  
  /**
   * Scenarion with first booking, 3 times campsite, 2 times house, scaling a
   */
  public function testScenario01()
  {
    $scaling = $this->getPriceScalingA();
    $bookings = $this->getBookingsEmpty();
    $payments = $this->getPaymentsEmpty();
    $tents = $this->getTentsA();
    
    $pc = new PriceCalculator($scaling, $bookings, $payments, $tents);
    
    $this->assertEquals(0, $pc->getAmountPayed());
    
    /*
     * campsite:	3	x	60.00	=	180.00
     * house		2	x	70.00	=	140.00
     * 									320.00
     */
    $this->assertEquals(320, $pc->getAmountDue());
  }
  
  private function getPriceScalingA() {
    $ps = new PriceScaling();
    $ps->setPriceCampsite(60.00);
    $ps->setPriceHouse(70.00);
    return $ps;
  }
  
  private function getPriceScalingB() {
    $ps = new PriceScaling();
    $ps->setPriceCampsite(80.00);
    $ps->setPriceHouse(90.00);
    return $ps;
  }
  
  private function getBookingsEmpty() {
    return new Doctrine_Collection('Booking');
  }
  
  private function getPaymentsEmpty() {
    return new Doctrine_Collection('Payment');
  }
  
  private function getTentsA() {
    $coll = new Doctrine_Collection('Tent');
    
    $t = new Tent();
    $t->setType('a');
    $t->setCapacity('3');
    $coll->add($t);
    
    $t = new Tent();
    $t->setType('h');
    $t->setCapacity('2');
    $coll->add($t);
    
    return $coll;
  }
  
  
}